using System;
using UnityEngine;

[Serializable]
public class FPSCounter : MonoBehaviour
{
	public float updateInterval;

	public int x_location;

	public int y_location;

	private double lastInterval;

	private int frames;

	private float fps;

	public FPSCounter()
	{
		updateInterval = 0.5f;
		x_location = 5;
		y_location = 5;
	}

	public void Awake()
	{
		useGUILayout = false;
	}

	public void OnGUI()
	{
		GUI.Label(new Rect(Screen.width - x_location, Screen.height - y_location, 100f, 30f), "FPS: " + fps.ToString("f2"));
	}

	public void Start()
	{
		lastInterval = Time.realtimeSinceStartup;
		frames = 0;
	}

	public void Update()
	{
		frames++;
		float realtimeSinceStartup = Time.realtimeSinceStartup;
		if (!((double)realtimeSinceStartup <= lastInterval + (double)updateInterval))
		{
			fps = (float)((double)frames / ((double)realtimeSinceStartup - lastInterval));
			frames = 0;
			lastInterval = realtimeSinceStartup;
		}
	}

	public void Main()
	{
	}
}
